__author__ = 'el_even'

import json
import omnistructure

headers = json.loads(open("jason.json").read())

omnidic = {}
omnitempdic = {}

for i in range(0, len(headers['log']['entries'])-1):
    # cutting off useless items
    if headers['log']['entries'][i]['request']['queryString'] != []:
        # filtering omniture requests
        if headers['log']['entries'][i]['request']['queryString'][0]['name'] == 'fid':
            omniquery = headers['log']['entries'][i]['request']['queryString']
            for k in range(0, len(omniquery)):
                omnitempdic[omniquery[k]['name']] = omniquery[k]['value']


for i in range(0, len(omnitempdic)):
    if omnitempdic.keys()[i] in omnistructure.omniheaders.keys():
        omnidic[omnistructure.omniheaders.get(omnitempdic.keys()[i])] = omnitempdic.values()[i]

#print 'parsed omniture headers:', omnidic

action = 'forum'

for i in range(0, len(omnidic)):
    tempkey = omnidic.keys()[i]
    if tempkey in omnistructure.mode.get(action).keys():
        if omnidic.get(tempkey) == omnistructure.mode.get(action).get(tempkey):
            print '^_^',
        else:
            print 'x_x',
        print tempkey, 'G:', omnidic.get(tempkey), 'N:', omnistructure.mode.get(action).get(tempkey)
    else:
        print 'O_o', tempkey, 'G:', omnidic.get(tempkey), 'N: NO NEED'

